package generatedClasses;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import struts.*;
import struts.tools.*;

public class WebSiteConfiguration
{
  protected static String nl;
  public static synchronized WebSiteConfiguration create(String lineSeparator)
  {
    nl = lineSeparator;
    WebSiteConfiguration result = new WebSiteConfiguration();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "\t";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     WebSite webSite = (WebSite) argument;
    IVisitor jspVisitor=new JSPVisitor(); 

    stringBuffer.append(TEXT_1);
    webSite.accept(jspVisitor,null);
	Generator.generateProject(null);	
	
	ArrayList<Data> pagesData=WebSiteData.getDataPages();
	HashMap<String,String> ressources=WebSiteData.getRessources();
	
	for(Data data:pagesData){
		Generator.generateJspDoc(data);
		
		for(Entry<String,ArrayList<DataElement>> entry:data.getFormData().entrySet()){
				String cle=entry.getKey();
				ArrayList<DataElement> formElts=entry.getValue();
				Generator.generateContact(formElts);
				Generator.generateContactValidationForm(formElts);
				Generator.generateDAOContact(formElts);
				Generator.generateContactAction(formElts);
		}
   }	 
   	Generator.generateRessourceFile(ressources);
   	Generator.generateWebXml();
	Generator.generateStrutsConfig();
	Generator.generateDTOListContact();
	
    return stringBuffer.toString();
  }
}
